<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    {{msg}}
    <br>
    <my-component>
      <h2>你好插槽</h2>
      <!-- <template v-slot:slot1="{ data1, data2 }"> -->
      <template v-slot:slot1="scope">
        {{scope.data1}}
        <br>
        {{scope.data2}}
        <div>插槽1传入值</div>
      </template>

      <template #slot2>
        <div>插槽2传入值</div>
      </template>
    </my-component>
  </div>
  <script>
    let myComponent = {
      data(){
        return {
          componentData: '我是组件中的数据'
        }
      },
      template: `
        <div>
          <div>
            <slot></slot>
            <slot name="slot1" :data1="componentData" data2="组件数据2">插槽1默认值</slot>
            <button>组件按钮</button>
            <slot name="slot2">插槽2默认值</slot>
          </div>
        </div>
      `
    }
    Vue.component('my-component',myComponent);
    let vm = new Vue({
      el: '#app',
      data: {
        msg:'hello 插槽'
      }
    })
  </script>
</body>
</html>